﻿using Newtonsoft.Json;
using PinusTools.DataConverter;
using PinusTools.Enums;

namespace GameSdk
{
    public class CommonHelper
    {
        public static byte[] SendMessage(int reqId, string route, object msg)
        {
            var type = reqId > 0 ? MessageEnum.TYPE_REQUEST : MessageEnum.TYPE_NOTIFY;
            var strJson = JsonConvert.SerializeObject(msg, Formatting.None);
            var data = Protocol.StrEncode(strJson);

            var msgData = Message.Encode(reqId, type, route, data);
            var sendData = Package.Encode(PackageEnum.TYPE_DATA, msgData);

            return sendData;
        }
    }
}